import download from "downloadjs";

export default class DownloadUnit {

    public static down(url:string,fileName:string) {
        let xhr = new XMLHttpRequest();
        xhr.open('GET', url, true);
        xhr.responseType = "blob";
        xhr.onload = function () {
            if (this.status === 200) {
                var blob = this.response;
                download(blob,fileName)
            } else {
                console.log('下载失败');
            }
        };
        xhr.send();
    }

}